#include "rclcpp/rclcpp.hpp"
#include "turtlesim/msg/pose.hpp"
using turtlesim::msg::Pose;
using std::placeholders::_1;

class TurtlePose :public rclcpp::Node
{
public:
    TurtlePose(const std::string &node_name):Node(node_name)
    {
        subscription_=this->create_subscription<Pose>("/turtle1/pose",10,
        std::bind(&TurtlePose::pose_call_back,this,_1));
    }
private:
    void pose_call_back(const Pose &msg)const
    {
        auto angular=msg.angular_velocity;
        auto theta=msg.theta;
        auto x=msg.x;
        auto y=msg.y;
        auto linear=msg.linear_velocity;
        RCLCPP_INFO(this->get_logger(),"x:%.2f y:%.2f theta:%.2f angular:%.2f linear:%.2f",
        x,y,theta,angular,linear);
    }    
    rclcpp::Subscription<Pose>::SharedPtr subscription_;
};
int main(int argc,char*argv[])
{
    rclcpp::init(argc, argv);
    rclcpp::spin(std::make_shared<TurtlePose>("turtle_pose_node_cpp"));
    rclcpp::shutdown();
    return 0;
}